package com.schedule.utils;

public class UserIdUtil {
    // 创建一个用户上下文工具类  线程本地变量存储类。
        private static final ThreadLocal<Long> userIdThreadLocal = new ThreadLocal<>();

        public static void setUserId(Long userId) {
            userIdThreadLocal.set(userId);
        }

        public static Long getUserId() {
            return userIdThreadLocal.get();
        }

        public static void remove() {
            userIdThreadLocal.remove();
        }
}
